//
//  PayBadViewController.m
//  MagazineShangejie
//
//  Created by cnbizMedia on 15/11/18.
//  Copyright © 2015年 CnbizMedia. All rights reserved.
//

#import "PayBadViewController.h"
#import "SettingTableViewController.h"
#import "MainTabBarController.h"
@interface PayBadViewController ()
{
    MainTabBarController*MainTabBar;
    
}
@property(strong,nonatomic)NSDictionary*Push_dic;
@end

@implementation PayBadViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"支付结果";
    //    self.hidesBottomBarWhenPushed = YES;
    
    //自定义bar按钮
    UIButton *buttonf=[UIButton buttonWithType:UIButtonTypeCustom];
    [buttonf setFrame:CGRectMake(0, 0, 40, 30)];
    [buttonf addTarget:self action:@selector(popOfDismss) forControlEvents:UIControlEventTouchUpInside];
//    [buttonf setImage:[UIImage imageNamed:@"dismiss"] forState:UIControlStateNormal];
    [buttonf setTitle:@"完成" forState:UIControlStateNormal];
    
//    [buttonf.tit .]
    [buttonf setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
//    [buttonf setBackgroundColor:[UIColor greenColor]];
     UIBarButtonItem*leftBarItem = [[UIBarButtonItem alloc]initWithCustomView:buttonf];
    self.navigationItem.rightBarButtonItem=leftBarItem;
    
    
    //添加返回手势
    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(popOfDismss)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [[self view] addGestureRecognizer:recognizer];
    
    

}


- (IBAction)cellPhone:(id)sender {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://023-88739152"]];
}
- (void)popOfDismss{
    //    [self.navigationController popToRootViewControllerAnimated:YES];
//    UIStoryboard*story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
//    SettingTableViewController *choo=[story instantiateViewControllerWithIdentifier:@"SettingTableViewController"];
//    //        opin.view.backgroundColor=[UIColor colorWithWhite:0.890 alpha:1.000];
//    //        [opin opinionInWWW:1];
//    [self.navigationController pushViewController:choo animated:YES];

//    [self.navigationController popViewControllerAnimated:YES];
//    [self MainVC];
    
    
        if ([[self.navigationController viewControllers] count]>=2) {
            //        self.hidesBottomBarWhenPushed = NO;
//            [self.navigationController popViewControllerAnimated:YES];
    [self.navigationController popToRootViewControllerAnimated:YES];
            
        }else{
            //    self.hidesBottomBarWhenPushed = NO;
            [self dismissViewControllerAnimated:YES completion:nil];
        }
}


-(void)setPush_dic:(NSDictionary *)Push_dic{
    SettingTableViewController*table=(SettingTableViewController*)[MainTabBar.customizableViewControllers[0] topViewController];
//    table.push_dic=Push_dic;
}
-(void)MainVC{
    UIStoryboard*story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    if(MainTabBar != nil){
//        if(self.Push_dic!=nil){
            SettingTableViewController *table=(SettingTableViewController*)[MainTabBar.viewControllers[0] topViewController];
            //            ArticleViewController*ar=[story instantiateViewControllerWithIdentifier:@"ArticleViewController"];
            //[self presentViewController:ar animated:YES completion:nil];
            //[self.drawerController.centerViewController presentViewController:ar animated:YES completion:nil];
            //            table.push_dic=self.Push_dic;
//            [self presentViewController:MainTabBar animated:YES completion:^{table.push_dic=self.Push_dic;
//            }];
//            return;
//        }else{
//            [self presentViewController:MainTabBar animated:YES completion:nil];
//        }
    }
    
     [self presentViewController:MainTabBar animated:YES completion:nil];
    //    SlideTableViewController*slide=[story instantiateViewControllerWithIdentifier:@"SlideTableViewController"];
    MainTabBar=[story instantiateViewControllerWithIdentifier:@"MainTabBarController"];
    //    self.drawerController = [[MMDrawerController alloc]
    //                             initWithCenterViewController:MainTabBar
    //                             leftDrawerViewController:nil
    //                             rightDrawerViewController:slide];
    //    [self.drawerController setRestorationIdentifier:@"MMDrawer"];
    //
    //
    //    [self.drawerController setMaximumRightDrawerWidth:self.view.frame.size.width*0.6];
    //
    //    [self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
    //
    //    [self.drawerController
    //     setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
    //         MMDrawerControllerDrawerVisualStateBlock block;
    //
    //         if(block){
    //             block(drawerController, drawerSide, percentVisible);
    //         }
    //     }];
    
    self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
